From: kaf24@firebug.cl.cam.ac.uk Date: Thu, 5 Oct 2006 11:08:08 +0000 (+0100) Subject: [MBOOTPACK] Fix building mbootpack on x86/64. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15615^2~47 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ff858e5b2fbe168244aee181e1e2510af933c8d5;p=xen.git [MBOOTPACK] Fix building mbootpack on x86/64. Signed-off-by: Keir Fraser --- diff --git a/tools/misc/mbootpack/Makefile b/tools/misc/mbootpack/Makefile index 18116688f3..d4ac73d954 100644 --- a/tools/misc/mbootpack/Makefile +++ b/tools/misc/mbootpack/Makefile @@ -20,12 +20,8 @@ install: build # Tools etc. RM := rm -f -GDB := gdb INCS := -I. -I- DEFS := -LDFLAGS := -CFLAGS += -Wpointer-arith -Wcast-qual -Wno-unused -Wno-format -CFLAGS += -Wmissing-prototypes -pipe # What object files need building for the program OBJS := mbootpack.o buildimage.o @@ -35,22 +31,22 @@ DEPFLAGS = -Wp,-MD,.$(@F).d DEPS = .*.d mbootpack: $(OBJS) - $(HOSTCC) -o $@ $(filter-out %.a, $^) + $(HOSTCC) $(HOSTCFLAGS) -o $@ $(filter-out %.a, $^) .PHONY: clean clean: $(RM) mbootpack *.o $(DEPS) bootsect setup bzimage_header.c bin2c bootsect: bootsect.S - $(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o + $(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c bootsect.S -o bootsect.o $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary bootsect.o -o $@ setup: setup.S - $(CC) $(CFLAGS) $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o + $(CC) -m32 $(INCS) $(DEFS) -D__MB_ASM -c setup.S -o setup.o $(LD) -m elf_i386 -Ttext 0x0 -s --oformat binary setup.o -o $@ bin2c: bin2c.o - $(HOSTCC) -o $@ $^ + $(HOSTCC) $(HOSTCFLAGS) -o $@ $^ bzimage_header.c: bootsect setup bin2c ./bin2c -n 8 -b1 -a bzimage_bootsect bootsect > bzimage_header.c @@ -59,11 +55,8 @@ bzimage_header.c: bootsect setup bin2c buildimage.c: bzimage_header.c @ -%.o: %.S - $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ - %.o: %.c - $(HOSTCC) $(DEPFLAGS) $(CFLAGS) $(INCS) $(DEFS) -c $< -o $@ + $(HOSTCC) $(DEPFLAGS) $(HOSTCFLAGS) $(INCS) $(DEFS) -c $< -o $@ .PRECIOUS: $(OBJS) $(OBJS:.o=.c) $(DEPS) .SUFFIXES: diff --git a/tools/misc/mbootpack/buildimage.c b/tools/misc/mbootpack/buildimage.c index a69d214684..bcf8303557 100644 --- a/tools/misc/mbootpack/buildimage.c +++ b/tools/misc/mbootpack/buildimage.c @@ -25,8 +25,6 @@ * */ - - #include #include #include @@ -77,20 +75,22 @@ /* Bring in the bzImage boot sector and setup code */ #include "bzimage_header.c" +#define _p(x) ((void *)(unsigned long)(x)) + address_t place_mbi(long int size) /* Find space at the top of *low* memory for the MBI and associated red tape */ { address_t start; start = 0xa000 - size; if (start < 0x9000 + sizeof(bzimage_bootsect) + sizeof(bzimage_setup)) { - printf("Fatal: command-lines too long: need %i, have %i bytes\n", + printf("Fatal: command-lines too long: need %ld, have %ld bytes\n", size, - 0x1000 - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup))); - exit(1); + 0x1000L - (sizeof(bzimage_bootsect) + sizeof(bzimage_setup))); + exit(1); } if (!quiet) { printf("Placed MBI and strings (%p+%p)\n", - start, size); + _p(start), _p(size)); } return start; } @@ -108,7 +108,7 @@ void make_bzImage(section_t *sections, /* Patch the kernel and mbi addresses into the setup code */ *(address_t *)(bzimage_setup + BZ_ENTRY_OFFSET) = eswap(entry); *(address_t *)(bzimage_setup + BZ_MBI_OFFSET) = eswap(mbi); - if (!quiet) printf("Kernel entry is %p, MBI is %p.\n", entry, mbi); + if (!quiet) printf("Kernel entry is %p, MBI is %p.\n",_p(entry), _p(mbi)); /* Write out header and trampoline */ if (fseek(fp, 0, SEEK_SET) < 0) { @@ -127,8 +127,9 @@ void make_bzImage(section_t *sections, exit(1); } - if (!quiet) printf("Wrote bzImage header: %i + %i bytes.\n", - sizeof(bzimage_bootsect), sizeof(bzimage_setup)); + if (!quiet) printf("Wrote bzImage header: %ld + %ld bytes.\n", + (long)sizeof(bzimage_bootsect), + (long)sizeof(bzimage_setup)); /* Sorted list of sections below 1MB: write them out */ for (s = sections, i = 0; s; s = s->next) { diff --git a/tools/misc/mbootpack/mbootpack.c b/tools/misc/mbootpack/mbootpack.c index 3e4cd51a99..c80fdeb975 100644 --- a/tools/misc/mbootpack/mbootpack.c +++ b/tools/misc/mbootpack/mbootpack.c @@ -128,6 +128,7 @@ static void usage(void) exit(1); } +#define _p(x) ((void *)(unsigned long)(x)) static void place_kernel_section(address_t start, long int size) /* Place the kernel in memory, checking for the memory hole. */ @@ -136,7 +137,8 @@ static void place_kernel_section(address_t start, long int size) /* Above the memory hole: easy */ next_free_space = MAX(next_free_space, start + size); if (!quiet) { - printf("Placed kernel section (%p+%p)\n", start, size); + printf("Placed kernel section (%p+%p)\n", + _p(start), _p(size)); } return; } @@ -144,14 +146,14 @@ static void place_kernel_section(address_t start, long int size) if (start >= MEM_HOLE_START) { /* In the memory hole. Not so good */ printf("Fatal: kernel load address (%p) is in the memory hole.\n", - start); + _p(start)); exit(1); } if (start + size > MEM_HOLE_START) { /* Too big for low memory */ printf("Fatal: kernel (%p+%p) runs into the memory hole.\n", - start, size); + _p(start), _p(size)); exit(1); } @@ -159,7 +161,7 @@ static void place_kernel_section(address_t start, long int size) next_free_space = MAX(next_free_space, start + size); if (!quiet) { - printf("Placed kernel section (%p+%p)\n", start, size); + printf("Placed kernel section (%p+%p)\n", _p(start), _p(size)); } } @@ -182,14 +184,12 @@ static address_t place_section(long int size, int align) if (!quiet) { printf("Placed section (%p+%p), align=%p\n", - start, size, align); + _p(start), _p(size), _p(align)); } return start; } - - static address_t load_kernel(const char *filename) /* Load an elf32/multiboot kernel from this file * Returns the entry address for the kernel. */ @@ -296,7 +296,7 @@ static address_t load_kernel(const char *filename) size = loadsize; if (loadsize > size) { - printf("Fatal: can't load %i bytes of kernel into %i bytes " + printf("Fatal: can't load %ld bytes of kernel into %ld bytes " "of memory.\n", loadsize, size); exit(1); } @@ -466,8 +466,6 @@ static address_t load_kernel(const char *filename) } - - int main(int argc, char **argv) { char *buffer, *imagename, *command_line, *p; @@ -480,7 +478,7 @@ int main(int argc, char **argv) struct mod_list *modp; address_t start, kernel_entry; long int size, mod_command_line_space, command_line_len; - int modules, opt, mbi_reloc_offset, make_multiboot; + int modules, opt, mbi_reloc_offset; static const char short_options[] = "hc:m:o:qM"; static const struct option options[] = {